/**
 * ReportGear(2011)
 */
package com.reportgear.core.data;

import java.util.List;
import java.util.Set;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;

import com.reportgear.core.data.model.SalaryDataObject;
import net.abbp.core.util.StringUtils;
import net.abbp.report.utils.Dom4jUtils;

/**
 * 通过本地方式查询XML数据，一般用于测试
 * 
 * @version 1.0 2011-5-28
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class SalaryDataQueryXmlByLocal extends AbstractSalaryDataQueryXml {
    @Override
    public List<SalaryDataObject> getOrgs() {
        return this.xmlDataToList(this.loadLocalXml("GetOrgs.ashx"));
    }

    @Override
    public List<SalaryDataObject> getCenters() {
        return this.xmlDataToList(this.loadLocalXml("GetCenters.ashx"));
    }

    @Override
    public List<SalaryDataObject> getSalaryScheme() {
        return this.xmlDataToList(this.loadLocalXml("GetSalarySystems.ashx"));
    }

    @Override
    public List<SalaryDataObject> getSalaryItem(int schemeId) {
        return this.xmlDataToList(this.loadLocalXml("GetSalaryItemsBySysID.ashx"));
    }

    @Override
    public String loadTemplate(int reportId) {
        return this.loadLocalXml("GetTemplateByID.ashx");
    }

    @Override
    public List<SalaryDataObject> loadTemplateList() {
        return this.xmlDataToList(this.loadLocalXml("GetTemplates.ashx"));
    }

    @Override
    public int saveTemplate(String template, int id, String name) {
        System.out.println(template);
        return 0;
    }

    @Override
    public boolean deleteTemplate(int id) {
        return true;
    }

    @Override
    public List<SalaryDataObject> getLastPayments() {
        return this.xmlDataToList(this.loadLocalXml("GetSalaryPayInfos.ashx"));
    }

    @Override
    public SalaryDataObject getSessionVar() {
        return this.xmlRootToList(this.loadLocalXml("GetUserInfo.ashx"));
    }

    @Override
    public SalaryDataObject getPayBase(int payId) {
        Document doc = Dom4jUtils.createDocument(this.loadLocalXml("GetSalaryPayInfo.ashx"));
        Element root = doc.getRootElement();

        SalaryDataObject sdo = new SalaryDataObject();
        for (Object ao : root.attributes()) {
            Attribute aa = (Attribute) ao;

            sdo.setValue(aa.getName(), StringUtils.trim(aa.getValue()));
        }

        return sdo;
    }

    @Override
    public List<SalaryDataObject> getOrderInfo(String key) {
        return this.xmlDataToList(this.loadLocalXml("GetSalaryQuerySettingInfo.ashx"));
    }

    @Override
    public int saveOrderInfo(String key, String content) {
        System.out.println(content);
        return 1;
    }

    private String loadLocalXml(String id) {
        Document doc = Dom4jUtils.createDocumentFromFile("c:\\\\report\\" + id + ".xml");

        return doc.asXML();
    }

    @Override
    public boolean deleteResumeTemplateModel(int id) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public String loadResumeTemplateModel(int id) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public List<SalaryDataObject> loadResumeTemplateModelList() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int saveResumeTemplateModel(String template, int id, String name, int isglobal) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public SalaryDataObject getResumeBase(int id) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public List<SalaryDataObject> getResumeParts(int id, String part) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getPhotoData(String photoId) {
        return null;
    }

    /*
     * (non-Javadoc)
     * @see
     * com.reportgear.core.data.SalaryDataQueryDelegate#loadResumeTemplateModelList1
     * ()
     */
    @Override
    public List<SalaryDataObject> loadResumeTemplateModelList1() {
        // TODO Auto-generated method stub
        return null;
    }
}
